package b4.view.component.basic
{
	import b4.util.BFont;
	import b4.util.GameProfile;
	
	import com.greensock.*;
	
	import flash.filters.*;
	import flash.text.*;
	
	public class PopMessage extends BasicWidget
	{
		public function PopMessage(msg:String, color:uint = 0x000000, glowColor:uint = 0xFFFFFF, textSize:int = 24)
		{
			super();
			
			this.anchor = BasicWidget.ANCHOR_MIDDLE_MIDDLE;

			//具体信息
			var tipText:TextField = new TextField();
			tipText.selectable = false;
        	tipText.autoSize = TextFieldAutoSize.LEFT;
			
        	var textFormat:TextFormat;
        	textFormat = new TextFormat(BFont.DEFAULT_FONT, textSize, color, true);
        	tipText.filters = [new GlowFilter(glowColor, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			tipText.defaultTextFormat = textFormat;
			tipText.text = msg;
			addChild(tipText);
			if (tipText.width > 2 * GameProfile.stageWidth / 3)
			{
	        	tipText.wordWrap = true;
	        	tipText.width = 2 * GameProfile.stageWidth / 3;
	  		}
			this.x = -this.width / 2;
			this.y = -this.height / 2;
			TweenLite.delayedCall(1.2, disappear);
		}
		
		//消失
		public function disappear():void
		{
			TweenLite.to(this, 1, {x:this.x, y:this.y - 30, alpha:0, onComplete:close});
		}
	}
}